package com.ejlchina.tool.view

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.ejlchina.tool.extension.toPx

class HorizontalItemDecoration(private val spacing: Int = 10): RecyclerView.ItemDecoration() {

    override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
        super.getItemOffsets(outRect, view, parent, state)
        val position = parent.getChildAdapterPosition(view)
        if (position != 0){
            outRect.top = parent.context.toPx(spacing).toInt()
        }
    }
}